import { Loading } from 'element-ui'

const LOADING_TIMEOUT = 0

let loading
let timeout

export default {
  show() {
    timeout = setTimeout(() => {
      loading = Loading.service({
        fullscreen: true,
        body: true,
        lock: true
      })
    }, LOADING_TIMEOUT)
    return loading
  },

  hide() {
    if (loading) {
      loading.close()
    }
    clearTimeout(timeout)
    return loading
  }
}
